﻿Type=Activity
Version=6
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.
	Private nPtr As Int
	Private tmr As Timer
	Private edtphone As EditText
	Private edtsmscode As EditText
	Private lblgetsmscode As Label
	Private edtpaypwd As EditText
	Private edtpaypwd2 As EditText
	Private Panel1 As Panel
	Private btnleft As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim telaw As telanywhere
telaw.Initialize(Activity)

	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("laymodifypaypwd")
	initviews
End Sub
Sub initviews
	comm.setFA(btnleft,"fa-angle-left","")
	comm.SetEdtStyle(Panel1,True)
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub reqSmsCode(mobile As String)
	ProgressDialogShow("正在获取验证码")
	ParseHelper.doGetReq(Me,"sms",comm.getApi(comm.apiIdx.REQSMS),Array As String("usertel",mobile))
End Sub
Sub ivback_Click
	Activity.Finish
End Sub
'提交
Sub btnreset_Click
	If edtphone.Text.Trim.Length<>11 Then
		comm.TL("请填写手机号")
		Return
	End If
	If edtpaypwd.Text.Trim.Length<1 Or edtpaypwd2.Text.Trim.Length<1 Then
		comm.TL("密码不能为空")
		Return
	End If
	If edtpaypwd.Text.Trim.CompareTo(edtpaypwd2.Text.Trim)<>0 Then
		comm.TL("两次输入的密码不同,请重新输入")
		Return
	End If
	If edtsmscode.Text.Trim.Length<1 Then
		comm.TL("请先获取短信验证码")
		Return
	End If
	reqpaypwdchg(edtphone.Text.Trim,edtsmscode.Text.Trim,edtpaypwd.Text.Trim,0)
End Sub
Sub JobDone(thj As HttpJob)
	ProgressDialogHide
	If thj.Success Then
		Dim str As String=thj.GetString
		Log(str)
		'Return
		Dim nr As netRes=ParseHelper.getStatusData(str)
		If nr.nCode=200 Then
			Select thj.JobName
			Case "sms"
				comm.TL("验证码获取成功")
				nPtr=60
				tmr.Initialize("tmr",1000)
				tmr.Enabled=True
			Case "paypwdchg"
				comm.TL("修改支付密码成功")
				Activity.Finish
'				'短信登录
'				'更新cookie
'				Log(str)
'				ParseHelper.updateCookie(thj.GetHeader)
'				ParseHelper.parseMyInfo(str)
'				g_store.conf.Put("islogin",True)
'				CallSubDelayed(actmain,"fillmyinfo")
'				Activity.Finish
			End Select
		Else
			comm.TL("错误:"&nr.sData)
		End If
	Else
		comm.TL("网络错误:"&thj.JobName&" "&thj.ErrorMessage)
	End If
	thj.Release
End Sub
Sub reqpaypwdchg(usertel As String,smscode As String,pay_pwd As String,is_teach As String)
	comm.showProgress("正在提交修改请求")
	ParseHelper.doPostReqArr(Me,"paypwdchg",comm.getApi(comm.apiIdx.REQPAYPWDCHG),Array As String("is_teach","0","pay_pwd",pay_pwd,"sms_code",smscode,"usertel",usertel),"")
	
End Sub
Sub tmr_Tick
	If nPtr>0 Then
		nPtr=nPtr-1
		lblgetsmscode.Enabled=False
		lblgetsmscode.Text=nPtr
		lblgetsmscode.TextColor=Colors.Black
	Else
		lblgetsmscode.Enabled=True
		lblgetsmscode.Text="验证码"
		lblgetsmscode.TextColor=Colors.White
		tmr.Enabled=False
	End If
End Sub
'获取短信验证码
Sub lblgetsmscode_Click
	If edtphone.Text.Trim.Length<>11 Then
		comm.T("手机号码不正确")
	Else
		reqSmsCode(edtphone.Text.Trim)
	End If
End Sub